//
//  ZWGoodsModel.m
//  aixianfeng
//
//  Created by zhaowei on 17/5/4.
//  Copyright © 2017年 zhaowei. All rights reserved.
//

#import "ZWGoodsModel.h"
#import "ZWHomeManager.h"

@implementation ZWGoodsModel

- (instancetype)init {
    
    
    self = [super init];
    if (self) {
        
        [self setup];
        
    }
    return self;
    
}


- (void)setup {
    
    NSDictionary *goodsDict = [_HomeManager requestHomeInfomation];
    NSArray *goodsArr = goodsDict[@"data"][@"act_info"][3][@"act_rows"];
    
    NSMutableArray *nameArr = [NSMutableArray array];
    NSMutableArray *imgArr = [NSMutableArray array];
    NSMutableArray *priceArr = [NSMutableArray array];
    
    for (NSInteger i =0; i<5; i++) {
        NSArray *goods = goodsArr[i][@"category_detail"][@"goods"];
        NSMutableArray *mutableName = [NSMutableArray array];
        NSMutableArray *mutableImg = [NSMutableArray array];
        NSMutableArray *mutablePrice = [NSMutableArray array];
        for (NSInteger j =0; j<3; j++) {
            [mutableName addObject:goods[j][@"name"]];
            [mutableImg addObject:goods[j][@"img"]];
            [mutablePrice addObject:goods[j][@"price"]];
            
        }
        [nameArr addObject:mutableName];
        [imgArr addObject:mutableImg];
        [priceArr addObject:mutablePrice];
    }
    
    //属性赋值
    self.nameArr = nameArr.copy;
    self.imageUrlArr = imgArr.copy;
    self.priceArr = (NSArray *)priceArr;
    
}

@end
